package com.yiming.shiro.repository;

import com.yiming.shiro.repository.entity.Permission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

@Repository
public interface PermissionRepository extends JpaRepository<Permission, Long> {

    @Query(value = "select p from Permission p where p.permissionId in (select rp.permissionId from RolePermission rp where rp.roleId in :roleIdSet)")
    List<Permission> findPermissionListByRoleId(@Param("roleIdSet") Set<Long> roleIdSet);
}
